<?php

use  yii\helpers\Url;
use  yii\helpers\Html;

$link = \backend\modules\models\setting\LinkCategory::find()->all();
?>
<div class="container-lg mt-4 mb-4 link-container">
    <div>
        <div class="link-title-detail">友情链接<span>:</span></div>
    </div>
    <div class="link-wrap row justify-content-md-center">
            <?php if ($link) { ?>
                <?php foreach ($link as $one => $first) : ?>
                <div class="col-md-3 col-6 detail-select-wrap">
                    <div class="dropdown">
                        <button class="btn btn-light dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                            <?= Html::encode($first->category) ?>
                        </button>
                        <?php if ($first->link) { ?>
                            <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
                                <?php foreach ($first->link as $two => $second) : ?>
                                    <a class="dropdown-item" href="<?= Html::encode($second->href) ?>" target="_blank"><?= Html::encode($second->name) ?></a>
                                <?php endforeach ?>
                            </div>
                        <?php } ?>
                    </div>
                </div>
                <?php endforeach ?>
            <?php } ?>
    </div>
</div>